package com.core.base;



import com.core.data.Reply;

import java.util.List;

/**
 * 分页查询使用的返回结果
 */
public class PagedReply<T> extends Reply<PageResult<T>> {

    public PagedReply() {
        super();
    }

    public PagedReply(PageResult<T> data) {
        this.setSuccess(true);
        this.setCode(0);
        this.setMessage("");
        setData(data);
    }

    public PagedReply(int index, int pageSize, long totalCount, List<T> data) {
        this.setSuccess(true);
        this.setCode(0);
        this.setMessage("");
        setData(new PageResult<>(index, pageSize, totalCount, data));
    }
    public static <T> PagedReply<T> success(int index, int pageSize, long totalCount, List<T> data) {
         return new PagedReply<>(index, pageSize, totalCount, data);
    }

    public static <T> PagedReply<T> pagedFailure(String message) {
        PagedReply reply = new PagedReply();
        reply.setSuccess(false);
        reply.setMessage(message);
        return reply;
    }
}
